const { JSDOM } = require('jsdom');
const fs = require('fs')

const SuperTask = require('./lib/SuperTask.js');

const bookString = fs.readFileSync('C:\\Users\\94876\\Desktop\\bookmarks_2024_11_1.html').toString()

const jsdom = new JSDOM(bookString);
// const jsdom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
const { document } = jsdom.window;

// 使用 querySelector 方法选取元素
const elems = document.querySelectorAll('a'); // 获取 <p> 元素
const superTask = new SuperTask(10);
const whiteList = [
    'blog.csdn.net',
    'www.youtube.com',
    'github.com',
    'www.jq22.com',
    'www.bilibili.com'
];
const isInWhiteList = (url)=>{
    return whiteList.some(i=>url.includes(i));
}
/*
elems.forEach((elem,index) => {
    const href = elem.getAttribute('href')
    const textContent = elem.textContent
    superTask.addTask(function (){
        return new Promise((resolve, reject)=>{
            if(isInWhiteList(href)){
                resolve()
                return
            }
            fetch(href)
                .then(res => res.text())
                .then(resolve)
                .catch(e=>{
                    reject([href,textContent])
                })
        })
    })
})
*/
const aaa = [
    [
        "https://www.html.cn/doc/chrome-devtools/settings/",
        "配置和自定义DevTools - Chrome 开发者工具中文文档 - html中文网"
    ],
    [
        "https://www.icode9.com/content-1-208176.html",
        "javascript – 替代JSON.parse()以维持小数精度？"
    ],
    [
        "https://www.w3cplus.com/canvas/drawing-curve.html",
        "Canvas学习：贝塞尔曲线_Canvas, Canvas学习 教程_w3cplus"
    ],
    [
        "https://6tail.cn/calendar/api.html",
        "lunar 农历库"
    ],
    [
        "https://www.teamgantt.com/",
        "Online Gantt Chart Software & Project Planning Tool | TeamGantt"
    ],
    [
        "https://www.giserdqy.com/frontend/js/36081/",
        "js自动生成guid唯一id - GIS开发者"
    ],
    [
        "http://www.ckplayer.com/",
        "ckplayer-超酷网页视频播放器"
    ],
    [
        "https://ckplayer.com/",
        "ckplayer"
    ],
    [
        "https://pr.oneplus.com/cn/videos/one",
        "一加手机视频|1+加手机官网"
    ],
    [
        "https://www.html.cn/doc/jsdoc/about-commandline.html",
        "JSDoc中的命令行参数 - JSDoc 中文文档 - html中文网"
    ],
    [
        "https://brm.io/matter-js/demo/#mixed",
        "Matter.js Demo"
    ],
    [
        "https://sources.ikeepstudying.com/mindmaptree-master/",
        "https://sources.ikeepstudying.com/mindmaptree-master/"
    ],
    [
        "http://www.xyhtml5.com/3274.html",
        "AOS – 另外一个独特的页面滚动动画库（CSS3） - HTML5教程 - 炫意HTML5"
    ],
    [
        "https://www.sass.hk/",
        "Sass世界上最成熟、稳定和强大的CSS扩展语言 | Sass中文网"
    ],
    [
        "https://space.bilibili.com/547874137/channel/series",
        "Cesium中文网的个人空间_哔哩哔哩_bilibili"
    ],
    [
        "https://campoallecomete.it/#!/en",
        "3D场景Campo alle comete - Sapori magici"
    ],
    [
        "https://zjbku.com/",
        "宅家呗"
    ],
    [
        "https://space.bilibili.com/1810581995/",
        "Lingo3D官方的个人空间_哔哩哔哩_bilibili"
    ],
    [
        "https://www.harp.gl/",
        "harp.gl"
    ],
    [
        "http://www.treejs.cn/v3/main.php#_zTreeInfo",
        "Home [zTree -- jQuery 树插件]"
    ],
    [
        "https://lingo3d.com/",
        "Lingo3D - 低代码元宇宙引擎"
    ],
    [
        "https://www.lingo3d.com/documentation/",
        "Lingo3D Documentation"
    ],
    [
        "https://www.openstreetmap.org/#map=4/36.96/104.17",
        "OpenStreetMap"
    ],
    [
        "https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL",
        "Overpass API/Overpass QL - OpenStreetMap Wiki"
    ],
    [
        "https://svip.z01x02.top/#/gamedetail/Steam/1245620?source=baidu&plan=%E8%89%BE%E5%B0%94%E7%99%BB%E6%B3%95%E7%8E%AFJZ&unit=%E8%89%BE%E5%B0%94%E7%99%BB%E6%B3%95%E7%8E%AF&keyword=%E6%B8%B8%E6%88%8F%E8%89%BE%E5%B0%94%E7%99%BB%E6%B3%95%E7%8E%AF&e_keywordid=396317869745&e_keywordid2=396317869745&bd_vid=11104700664728019497",
        "艾尔登法环"
    ],
    [
        "http://zuoben.top/",
        "左本Web3D"
    ],
    [
        "http://analysis.4sceners.de/#!/music",
        "Bitfellas Analysis"
    ],
    [
        "http://scr3.hnckljl.top/scratch_serv.html?keyword=487056671979&bd_vid=7027663994289703812",
        "Scratch下载 - Scratch3.0|Scratch2.0|Scratch1.0|少儿编程软件下载安装"
    ],
    [
        "http://scr3.hnckljl.top/scratch_serv.html?keyword=487056671979&bd_vid=7027663994289703812#",
        "Scratch下载 - Scratch3.0|Scratch2.0|Scratch1.0|少儿编程软件下载安装"
    ],
    [
        "https://beinternetawesome.withgoogle.com/en_us/interland/mindful-mountain",
        "Play Interland - Be Internet Awesome"
    ],
    [
        "http://laomengit.com/",
        "Flutter | 老孟"
    ],
    [
        "https://experiments.withgoogle.com/chrome/globe",
        "WebGL Globe - Experiments with Google"
    ],
    [
        "http://emas.weex.io/",
        "WEEX"
    ],
    [
        "http://emas.weex.io/tools/playground.html",
        "WEEX"
    ],
    [
        "http://emas.weex.io/docs/api/weex-variable.html",
        "Weex Variable | WEEX"
    ],
    [
        "http://stemkoski.github.io/Three.js/#hello-world",
        "Three.js - examples"
    ],
    [
        "https://developers.google.com/blockly/guides/overview",
        "Introduction to Blockly  |  Google Developers"
    ],
    [
        "https://blocklycodelabs.dev/",
        "Codelabs"
    ],
    [
        "https://www.mianshigee.com/project/robinwassen-electron-wallpaper/",
        "electron-wallpaper：一个Node 模块实现在Windows中将窗口附加为墙纸-面圈网"
    ],
    [
        "https://pro.autojs.org/",
        "Auto.js Pro"
    ],
    [
        "http://cml.didi.cn/",
        "Chameleon 变色龙 - 一套代码运行多端，一端所见即多端所见"
    ],
    [
        "https://book.flutterchina.club/chapter2/flutter_router.html#_2-2-1-%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E7%A4%BA%E4%BE%8B",
        "2.2 路由管理 | 《Flutter实战》电子书"
    ],
    [
        "https://demo.ucharts.cn/#/",
        "https://demo.ucharts.cn/#/"
    ],
    [
        "https://www.color-ui.com/",
        "Color Ui | 极其鲜亮的高饱和色彩，更注重视觉的小程序组件库"
    ],
    [
        "http://www.delphitop.com/",
        "Delphi编程技巧大全"
    ],
    [
        "http://demo.color-ui.com/",
        "ColorUI组件库"
    ],
    [
        "http://demo.weui.org.cn/example/",
        "WeUI"
    ],
    [
        "https://www.html.cn/archives/6245",
        "Zepto.js (1.2.0) API 中文文档-WEB前端开发"
    ],
    [
        "https://www.html.cn/doc/zeptojs_api/",
        "Zepto.js (1.2.0) API 中文文档-轻量级兼容jQuery的JavaScript库"
    ],
    [
        "https://market.kaikeba.com/vipcourse/w3rank?qr=13445101300202alni.png&utm_campaign=PC%E6%8E%A8%E5%B9%BF&utm_medium=cpc&utm_source=PC&gio_link_id=lPQ7ylD9",
        "开课吧-数字化人才在线教育平台"
    ],
    [
        "https://muse-ui.org/#/zh-CN",
        "Muse-UI"
    ],
    [
        "https://ueditor.baidu.com/website/onlinedemo.html",
        "UEditor - 示例"
    ],
    [
        "https://ueditor.baidu.com/website/document.html",
        "UEditor - 文档说明"
    ],
    [
        "https://nbcharts.com/map/map.php",
        "NB Map"
    ],
    [
        "https://www.w3cplus.com/vue/renderless-components-in-vuejs.html",
        "Vue中的无渲染组件_Vue, Vue组件 教程_w3cplus"
    ],
    [
        "https://www.redux.org.cn/",
        "Redux中文文档"
    ],
    [
        "https://www.dazhuanlan.com/2019/12/11/5df0711f9df60/",
        "vue组件内将其它组件挂载到body | 大专栏"
    ],
    [
        "https://ui-libs.vercel.app/",
        "UI Lib Picker 开代理才能看"
    ],
    [
        "https://pan.qiwenshare.com/docs/",
        "奇文网盘"
    ],
    [
        "https://www.pudn.com/news/62c92003b742fa794d97c1aa.html",
        "vue3.0使用intro.js实现新手引导功能-pudn.com"
    ],
    [
        "https://www.typescriptlang.org/play",
        "TypeScript: TS Playground - An online editor for exploring TypeScript and JavaScript"
    ],
    [
        "https://eslint.bootcss.com/",
        "ESLint - 插件化的 JavaScript 代码检测工具 - ESLint中文文档"
    ],
    [
        "http://www.daqianduan.com/6179.html",
        "CSS实现单行、多行文本溢出显示省略号（…）-大前端"
    ],
    [
        "http://www.css88.com/archives/8284",
        "2017年最佳 VS Code 主题 – WEB前端开发 - 专注前端开发，关注用户体验"
    ],
    [
        "https://www.html.cn/book/css/values/length/em.htm",
        "em_CSS属性_CSS参考手册 - html中文网"
    ],
    [
        "https://www.1024nav.com/tools/vue-tour",
        "一款简单易用的vue新手步骤引导组件 | 前端面经"
    ],
    [
        "https://cn.msi.com/Laptop/%E7%BB%9D%E5%BD%B12-GS66-10SFS-097CN",
        "Overview 绝影2 GS66 10SFS-097CN | 微星中国"
    ],
    [
        "https://account-cn.msi.com/home/service",
        "MSI 会员注册中心"
    ],
    [
        "https://www.wallpaperengine.io/zh-hans",
        "Wallpaper Engine：Windows 系统上的动画壁纸"
    ],
    [
        "https://store.steampowered.com/app/431960/",
        "Steam 上的 Wallpaper Engine：壁纸引擎"
    ],
    [
        "http://www.displore.com.cn/",
        "微及时-微信社群专业管理-微信协议-微信IPAD协议-微信API-微信接口-微信机器人-个人微信API"
    ],
    [
        "https://vue-admin-beautiful.com/admin-plus/#/login?redirect=/other/workflow",
        "Vue Admin Plus"
    ],
    [
        "https://jikaiyun.com/J2Paas",
        "J2PaaS低代码敏捷开发-快速开发平台-前端免代码工具-吉鼎科技吉开云生态圈"
    ],
    [
        "http://dooring.cn/editor/home",
        "H5页面制作平台-dooringx"
    ],
    [
        "https://www.kdocs.cn/l/cgBE7SmUhFdb",
        "不易的小米智能家居参考-易举不易"
    ],
    [
        "https://cc.cutecloud.cc/user",
        "用户中心 — 最萌の云 - CuteCloud 代理"
    ],
    [
        "https://rxeditor.vercel.app/",
        "rxeditor"
    ],
    [
        "https://172.17.18.8:8443/",
        "Gitblit188"
    ],
    [
        "https://www.kdocs.cn/group/2064579740",
        "金山文档 | WPS云文档"
    ],
    [
        "https://172.17.17.62:1443/!/#Project/view/head/2024-07-Com-Plantform_Files/NodePackages",
        "NodePackages"
    ],
    [
        "https://www.kdocs.cn/l/ceKAyp1NKHAl?from=docs&reqtype=kdocs&startTime=1721612392249&createDirect=true&newFile=true",
        "web3d增强"
    ],
    [
        "https://www.kdocs.cn/l/cqcMYaJSutDK",
        "版本更新"
    ],
    [
        "https://www.kdocs.cn/l/cc0d2PrizBOz",
        "平台工作日报"
    ],
    [
        "https://www.kdocs.cn/l/caGmXO5Sxtls",
        "项目组现场人员安排"
    ],
    [
        "https://form.avuejs.com/",
        "Avue表单设计器"
    ],
    [
        "https://124.128.247.188:1443/!/#Doc/view/head/%E5%85%AC%E5%8F%B8%E4%BA%A7%E5%93%81%E5%AD%A6%E4%B9%A0%E8%B5%84%E6%96%99",
        "Doc/公司产品学习资料 — VisualSVN Server"
    ],
    [
        "https://www.rpgmakerweb.com/",
        "Make Your Own Game with RPG Maker"
    ],
    [
        "https://lit.dev/",
        "Lit Web Components"
    ],
    [
        "https://resvg-js.vercel.app/",
        "resvg-js playground"
    ],
    [
        "https://www.pinterest.com/",
        "Pinterest"
    ],
    [
        "https://chat.openai.com/",
        "ChatGPT"
    ]
]
aaa.forEach((elem,index) => {
    const href = elem[0]
    const textContent = elem[1]
    superTask.addTask(function (){
        return new Promise((resolve, reject)=>{
            if(isInWhiteList(href)){
                resolve()
                return
            }
            fetch(href)
                .then(res => res.text())
                .then(resolve)
                .catch(e=>{
                    reject([href,textContent])
                })
        })
    })
})

superTask.doTask()
